<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="app">
  <cpn></cpn>
  <cpn></cpn>
  <cpn ref="aaa"></cpn>
  <button @click="btnClick">按钮</button>
</div>
<template id="cpn">
  <div>我是子组件</div>
</template>
<script src="../vue.js"></script>
<script>
  const app = new Vue({
    el: '#app',
    data: {
      message: 'hello',
    },
    methods:{
      btnClick(){
        // //访问子组件的methods
        // this.$children[0].showMessage()
        // //访问子组件的data
        // console.log(this.$children[0].name)
        console.log(this.$refs.aaa);
      }
    },
    components:{
      cpn:{
        template:`#cpn`,
        data(){
          return{
            name:'xqz'
          }
        },
        methods:{
          showMessage(){
            console.log('showMessage')
          }
        }
      }
    }
  })
</script>
</body>
</html>
